package com.itheima.web.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.Banner;


import com.itheima.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/banner")
public class BannerController {

    @Autowired
    BannerService bannerService;



    @GetMapping("/findByPage")
    public PageInfo<Banner> findByPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                       @RequestParam(value = "pageSize",defaultValue = "5") Integer pageSize,
                                       String keyword
                                       ){
       return bannerService.findByPage(pageNum,pageSize,keyword);
    }


    @PostMapping("/save")
   public  void  save(@RequestBody Banner banner){
        bannerService.save(banner);
    }
    @GetMapping("/findById")
    public Banner fndById(Integer id){
     return bannerService.findById(id);
    }

    @DeleteMapping("/deleteById")
    public void deleteById(Integer id){
        bannerService.delete(id);
    }

    @DeleteMapping("/deleteBatch")
    public void deleteBatch(Integer[] ids) {
        bannerService.deleteBanTch(ids);

    }
}
